<?php

use think\facade\Env;

return [
    // 扩展自身需要的配置
    'protocol' => 'websocket', // 协议 支持 tcp udp unix http websocket text
    'host' => '0.0.0.0', // 监听地址
    'port' => 2345, // 监听端口

    // 支持workerman的所有配置参数
    'name' => 'thinkphp',
    'count' => 4,
    'daemonize' => false,
    'pidFile' => Env::get('runtime_path') . 'worker.pid',

    //开启后本文件端口不可使用
    'worker_class' => [//可开启多个进程 controller
        'app\worker\controller\WaterVoice',
        'app\worker\controller\VoiceWorker',
        'app\worker\controller\EngineerVoice',
        'app\worker\controller\UserFace',
    ],

    // 支持事件回调
    // onWorkerStart
    'onWorkerStart' => function ($worker) {

    },
    // onWorkerReload
    'onWorkerReload' => function ($worker) {

    },
    // onConnect
    'onConnect' => function ($connection) {

    },
    // onMessage
    'onMessage' => function ($connection, $data) {

    },
    // onClose
    'onClose' => function ($connection) {

    },
    // onError
    'onError' => function ($connection, $code, $msg) {
        echo "error [ $code ] $msg\n";
    },

    //js 测试代码
    /*ws = new WebSocket("ws://127.0.0.1:2345");
    ws.onopen = function() {
        alert("连接成功");
        ws.send('{"type":"1","value":"111111"}');
        alert("给服务端发送一个字符串：hello,thinkphp");
    };
    ws.onmessage = function(e) {
        alert("收到服务端的消息：" + e.data);
    };*/
];